package com.bestv.datalake.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

import static com.google.common.base.Predicates.not;
import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;


@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket groupDemoDocket() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("Datalake").select().apis(
                basePackage("com.bestv.datalake.controller")).build().apiInfo(apiInfo());
    }

    @Bean
    public Docket groupHealthDocket() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("Health").select().apis(
                not(basePackage("com.bestv.datalake.controller"))).build().apiInfo(apiInfo());
    }


    private ApiInfo apiInfo() {
        final ApiInfo apiInfo = new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", "myeaddress@akcome.com", "License of API", "API license URL");
        return apiInfo;
    }
}